package com.study.forumsystemproject.dao;

import com.study.forumsystemproject.model.Message;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper {
    int insert(Message row);

    int insertSelective(Message row);

    Message selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Message row);

    int updateByPrimaryKey(Message row);

    /**
     * Description: 获取到未读的信息数量
     * Param:  receiveUserId
     * return: 未读的信息数量
     * Author: xiaoxie
     * Date: 23:30 2024/8/19
    */
    @Select("select count(*) from t_message where receiveUserId = #{receiveUserId} and state = 0 and deleteFlag = 0 ")
    Integer selectNotRedByReceiveUserId(Long receiveUserId);
    /**
     * Description: 根据接收者的ID获取接收的所有信息
     * Param:  receiveUserId 接收者id
     * return: 信息列表
     * Author: xiaoxie
     * Date: 18:22 2024/8/20
    */
   List<Message> getAllMessageByReceiveUserId(Long receiveUserId);
}